package com.qst.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qst.order.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Update("UPDATE t_user SET money = money - #{totalPrice} WHERE id = #{userId} AND money >= #{totalPrice}")
    boolean updateMoney(@Param("userId") Integer userId, @Param("totalPrice") BigDecimal totalPrice);
}
